package jk.spider.core.task.dispatch;

import org.apache.log4j.Logger;

import jk.spider.core.SpiderController;
import jk.spider.core.task.WorkerTask;
import jk.spider.core.task.threading.WorkerThreadPool;

public class DispatchThinkTasks extends DispatcherTask {
	protected static final Logger log = Logger.getLogger(DispatchThinkTasks.class);
	protected WorkerThreadPool thinks;
	protected SpiderController controller;
	protected int count = 0;
	
	public DispatchThinkTasks(SpiderController controller, WorkerThreadPool thinks) {
		super(controller, thinks);
		this.controller = controller;
		this.thinks = thinks;
	}
	
	public int getType() {
		return WorkerTask.WORKERTASK_PARSERTASK;
	}

	public void prepare() { }

	public void execute() {
		log.info("Thinks task dispatcher running ...");
		while(running) {
			try {
				thinks.assign(controller.getContent().getParserTask());
			} catch (InterruptedException e) {
				running = false;
			}
		}
		log.info("Tarser task dispatcher dying ...");
	}

}
